package com.mindbook.vip.gawxchatinfo.controller.nostrum;

import com.mindbook.vip.gawxchatinfo.entity.nostrum.PrimaryLiverCancerTreatmentProgrammeGroup;
import com.mindbook.vip.gawxchatinfo.service.nostrum.PrimaryLiverCancerTreatmentProgrammeGroupService;
import com.mindbook.vip.gawxchatinfo.utils.crud.CrudUtils;
import com.mindbook.vip.gawxchatinfo.utils.result.Result;
import com.mindbook.vip.gawxchatinfo.utils.result.ResultEnum;
import com.mindbook.vip.gawxchatinfo.utils.result.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @NAME: wxb
 * @DATE: 2022/8/9
 * @DESCRIPTION:
 **/
@Api(tags = "原发性肝癌治疗方案分组")
@RestController
@RequestMapping("primaryLiverCancerTreatmentProgrammeGroup")
public class PrimaryLiverCancerTreatmentProgrammeGroupController {

    @Autowired private PrimaryLiverCancerTreatmentProgrammeGroupService service;

    @ApiOperation("新增")
    @PostMapping("/")
    public Result add(PrimaryLiverCancerTreatmentProgrammeGroup p){
        Integer integer = service.addSelective(p);

        CrudUtils.validateAddResult(integer);

        return ResultUtils.genSuccessResult(ResultEnum.DATA_ADD_SUCCESS.getMsg());
    }

    @ApiOperation("修改")
    @PutMapping("/")
    public Result put(PrimaryLiverCancerTreatmentProgrammeGroup p){
        Integer integer = service.put(p);

        CrudUtils.validateAddResult(integer);

        return ResultUtils.genSuccessResult(ResultEnum.DATA_UPDATE_SUCCESS.getMsg());
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除")
    public Result del(@PathVariable Integer id){
        Integer integer = service.removeByPrimaryKey(id);

        CrudUtils.validateDeleteResult(integer);

        return ResultUtils.genSuccessResult(ResultEnum.DATA_DELETE_SUCCESS.getMsg());
    }

    @GetMapping("/list")
    @ApiOperation("列表")
    public Result selectList(){
        List<PrimaryLiverCancerTreatmentProgrammeGroup> all = service.findAll();

        return ResultUtils.genSuccessResult(all);
    }


}
